package com.itheima.pojo;

import lombok.Data;

import java.io.Serializable;

/**
 * 封装返回结果
 */
@Data
public class Result implements Serializable {

    private boolean flag;//执行结果，true为执行成功 false为执行失败

    private String message;//返回结果信息

    private Object data;//返回数据


    public Result(boolean flag) {
        super();
        this.flag = flag;
    }

    public Result(boolean flag, String message) {
        super();
        this.flag = flag;
        this.message = message;
    }

    public Result(boolean flag, Object data) {
        this.flag = flag;
        this.data = data;
    }

    public Result(boolean flag, String message, Object data) {
        this.flag = flag;
        this.message = message;
        this.data = data;
    }

    public static Result success() {
        return new Result(true);
    }

    public static Result success(Object data) {
        return new Result(true, data);
    }

    public static Result success(String message) {
        return new Result(true, message);
    }

    public static Result error(String message) {
        return new Result(false, message);
    }

}
